<?php
require_once("taskView.php");
require_once(CORE_DIR.'taskModel.php');

class getuserdonetasksAction extends authAction{

	function __construct(){
		$this->view = new taskView();
	}

	public function run($get, $post, $viewtype) {
		parent::run($get,$post,$viewtype);
		
		$tModel = new taskModel();		
		
		$period = isset($get["period"]) ? $get["period"] : "all";
		
		if (isset($get["userid"]))
		{
			if ($get["userid"] != "0")
			{
				$userId = $get["userid"];
				if(!strpos($userId, "|"))
					$tasks = $tModel->getUserDoneTasks($userId, $period);
				else
					$tasks = $tModel->getDoneTasksByUserList($userId, $period);
			}
			else
			{
				$tasks = $tModel->getUsersDoneTasks($period);
			}
			
			$this->view->setProperty("tasks", $tasks);
			$this->view->showGetUserDoneTasks();
		}
	}
}
?>